Skip to content

Non fxa migrated deletions #6611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2025

Conversation

akatsoulas
Copy link
Collaborator

No description provided.

This migration removes user accounts that meet both criteria:
1. Have not been migrated to Firefox Accounts (is_fxa_migrated=False)
2. Have no content or content relationships (no posts, votes, messages, etc.)
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a migration to delete non-FXA migrated users who have no associated content and adds a test suite to verify the query logic.

  • Adds a test case for the migration query logic in kitsune/users/tests/test_migration_0033.py
  • Implements the migration in kitsune/users/migrations/0033_batch_delete_non_migrated_users.py that deletes users in batches, with logging for progress reporting

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
kitsune/users/tests/test_migration_0033.py Introduces tests for various user content scenarios to validate deletion logic
kitsune/users/migrations/0033_batch_delete_non_migrated_users.py Implements batch deletion of non-migrated users with additional exclusion conditions
Comments suppressed due to low confidence (1)

kitsune/users/migrations/0033_batch_delete_non_migrated_users.py:34

  • Consider adding tests to cover the newly added exclusion conditions (locales_leader, locales_reviewer, locales_editor, and wiki_contributions) to ensure they are correctly preventing deletions when associated content exists.
| Q(locales_leader__isnull=False)

Copy link
Contributor

@escattone escattone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+wc

My only comment is that based on my experience with other mass deletions, a batch size of 2K seems lower than what we could safely do -- I would say we could at least do 10K -- but maybe it doesn't make much difference in the end anyway.

Copy link
Contributor

@smithellis smithellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+wc

| Q(wiki_contributions__isnull=False)
)

user_ids = list(users_to_delete.values_list("id", flat=True))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will load all million + into memory. Is this a good place to use iterator? Something like:

user_ids = users_to_delete.values_list("id", flat=True).iterator(chunk_size=2000)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is much better - that was my initial approach. The batching became more complex because of the slicing and calculating where to break out. The query will round up 800K which should be around 7MB

@akatsoulas
Copy link
Collaborator Author

I am taking another shot at this - I will ping you both when it's ready

@akatsoulas akatsoulas force-pushed the non-fxa-migrated-deletions branch from 698e714 to d0060f4 Compare April 7, 2025 14:03
@akatsoulas akatsoulas merged commit f132c31 into mozilla:main Apr 10, 2025
2 checks passed
@akatsoulas akatsoulas deleted the non-fxa-migrated-deletions branch April 10, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants